package com.iteleven.generator.trackTest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iteleven.generator.common.KafkaMsgSend;

import java.util.*;

/**
 * Created by angel
 */
public class UserBrowseRecord {

    private static String Udid = "6399e34ccde5cd5504f915dce67527af98e4ef7f";
    private static String ParkId = "63";
    private static Double[] lng = new Double[]{114.44896999782986,114.43896999782986, 114.42896999782986, 114.41896999782986};
    private static Double[] lat = new Double[]{30.478028700086806,30.468028700086806, 30.458028700086806, 30.448028700086806};
    private static String[] time = new String[]{"2019-10-17T11:53:17.000+08:00", "2019-10-17T15:53:17.000+08:00", "2019-10-17T16:53:17.000+08:00", "2019-10-16T12:53:17.000+08:00", "2019-10-16T13:53:17.000+08:00", "2019-10-16T14:53:17.000+08:00"};
    private static String gcode = "027";
    private static Double[] Altitude = new Double[]{38.274803161621094, 37.274803161621094, 36.274803161621094, 35.274803161621094};
    private static int Course = -1;
    private static int Speed = -1;
    private static String appVersion = "5.3.0";
    private static String terminalSystem = "1";
    private static String terminalType = "IphoneX";
    private static String networkType = "4G";
    private static String ip = "123.123.123.123";
    private static String IMEI = "";
    private static String IDFA = "20516E19-44CC-43CE-9342-2C12C310D955";
    private static String userId = "86c0461d-67af-44cf-928a-92ecd101115f";

    public static void main(String[] args) {

        Random random = new Random();
        for (int i = 0; i < 10000; i++) {
            String timeData = time[random.nextInt(time.length)];

            JSONObject jsonData = new JSONObject();
            jsonData.put("_id", UUID.randomUUID());
            jsonData.put("Udid", Udid);
            jsonData.put("ParkId", ParkId);
            jsonData.put("Lng", lng[random.nextInt(lng.length)]);
            jsonData.put("Lat", lat[random.nextInt(lat.length)]);
            jsonData.put("Time", timeData);
            jsonData.put("Gcode", gcode);
            jsonData.put("Altitude", Altitude[random.nextInt(Altitude.length)]);
            jsonData.put("Course", Course);
            jsonData.put("Speed", Speed);
            jsonData.put("CreateTime", timeData);
            jsonData.put("AppVersion", appVersion);
            jsonData.put("TerminalSystem", terminalSystem);
            jsonData.put("TerminalType", terminalType);
            jsonData.put("NetworkType", networkType);
            jsonData.put("IP", ip);
            jsonData.put("IMEI", IMEI);
            jsonData.put("IDFA", IDFA);
            jsonData.put("UserId", userId);

            String dataStr = JSON.toJSONString(jsonData);

            System.out.println(dataStr);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //todo:调用方法向指定的url发送数据,进而向kafka中发送数据
            KafkaMsgSend.send("http://localhost:8888/ReportToKafkaApplication/retriveData", "track_test", dataStr);
        }
    }
}